"""
    管理端登录页面类
"""
from selenium.webdriver.common.by import By

from base.base_page import BasePage

# 继承父类
class PageAdminLogin(BasePage):

    # 初始化要操作的元素和获取父类的浏览器驱动对象
    def __init__(self):
        # 初始化父类
        super().__init__()
        # 元素
        # 用户名
        self.username = (By.CSS_SELECTOR,"input[placeholder='Username']")
        # 密码
        self.password = (By.CSS_SELECTOR,"input[placeholder='Password']")
        # 登录按钮
        self.login_btn = (By.CSS_SELECTOR,".el-button.el-button--primary")
        # 登录成功后的标志“首页”
        self.login_success_ok = (By.CSS_SELECTOR,".no-redirect")

    def page_admin_login(self):
        # 输入用户名
        self.base_input_text(self.username,"fhj")
        # 输入密码
        self.base_input_text(self.password,"123456")
        # 点击登录
        self.base_click(self.login_btn)
        # 对登录后进行断言  登录成功后读取页面是否有”首页“这个字
        assert "首页" == self.base_get_text(self.login_success_ok)
        print(self.base_get_text(self.login_success_ok))


